<template>
  <div class="app-container01">
    <div class="filter-container bor-container">
      <el-form size="mini" :inline="true">
        <el-form-item>
          <div class="block">
            <span class="demonstration">创建时间：</span>
            <el-date-picker
              v-model="value"
              value-format='yyyy-MM-dd'
              type="daterange"
              :picker-options="pickerOptions"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="timeChange"
              align="right">
            </el-date-picker>
          </div>
        </el-form-item>
        <el-button size="mini" @click="query()" icon="el-icon-search">查询</el-button>
      </el-form>
    </div>
    <el-table class="per_tb" stripe v-loading="loading" border :data="tableData">

      <el-table-column prop="serialNo" label="流水号">
      </el-table-column>

      <el-table-column prop="createTime" label="创建时间">
      </el-table-column>

      <el-table-column prop="bankType" label="账户类型">
      </el-table-column>

      <el-table-column prop="cashAccount" label="账号">
      </el-table-column>

      <el-table-column prop="amount" label="提现金额">
      </el-table-column>

      <el-table-column prop="expectAmount" label="预计到账">
      </el-table-column>

      <el-table-column prop="title" label="提现状态">
        0 待审核，1已通过，2已拒绝
        <template slot-scope="scope">
            <el-tag v-if="scope.row.status == 0">待审核</el-tag>
            <el-tag v-else-if ="scope.row.status == 1">已通过</el-tag>
            <el-tag v-else-if="scope.row.status == 2">已拒绝</el-tag>
        </template>
      </el-table-column>

      <el-table-column prop="reason" label="备注">
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <a href="http://uchat.im-cc.com/webchat_new/static/html/index.html?ht=cxFmDV" target="_blank"><el-button  size="mini" type="warning"  icon="el-icon-edit-outline" >客服</el-button></a><br>
          <div style="height:10px;"></div>
          <el-button  size="mini" type="info" @click="openDetail(scope.row)" icon="el-icon-edit-outline" >详情</el-button>
        </template>
      </el-table-column>

    </el-table>
    <el-pagination
      class="pagination-right"
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="formInline.pageNum"
      :page-sizes="[10]"
      :page-size="formInline.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="formInline.total">
    </el-pagination>
    <detail-withdraw
      @close="close"
      @success="success"
      v-if="dialog.status"
      :model="data"
      :dialog_="dialog.status">
    </detail-withdraw>
  </div>
</template>
<script>
  import { getWithdrawListAPI } from "@/api/user";
  import { mapGetters } from 'vuex'
  import DetailWithdraw from './components/DetailWithdraw'
  export default {
    name: 'WithdrawList',
    components: { DetailWithdraw },
    data() {
      return {
        pickerOptions: {
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
              picker.$emit('pick', [new Date(), new Date()]);
            }
          },{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一年',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        value: '',
        data:'',
        formInline: {
          timeType: 0,//时间范围类型 0自定义范围，近一年：1，近一月：2，近一周：3,今日：4
          start:'',
          end:'',
          pageNum: 1,
          pageSize: 10
        },
        editUser: null, // 编辑时传入的对象
        loading: false,
        tableData: [],
        dialog: {
          status: false
        },
        dialogadd: {
          status: false
        }
      }
    },
    computed: {
      ...mapGetters([
        'buttons',
      ])
    },
    mounted() {
      this.getList()
    },
    methods: {
      // 时间发生改变的事件
      timeChange(value){
        debugger
        if(value == null){
          this.formInline.start = ''
          this.formInline.end = ''
        }else {
          this.formInline.start = this.value[0]
          this.formInline.end = this.value[1]
        }
        this.getList()
      },
      openAdd() {
        this.dialog.status = true
      },
      //增加编辑打开弹窗
      openEdit(obj) {
        debugger
        this.dialog.status = true
        this.data = obj
      },
      // 详情打开弹窗
      openDetail(obj) {
        debugger
        this.dialog.status = true
        this.data = obj
      },
      // 操作栏中的下拉框发生修改
      selectChange(obj) {
        debugger
        if (obj == '用户个人信息') {
          this.dialog.infoStatus = true
        }else if(obj == '提现记录'){
          this.dialog.withdrawStatus = true
        }else if(obj == '充值记录'){
          this.dialog.rechargeStatus = true
        }else if(obj == '账号管理'){
          this.dialog.accountStatus = true
        }else if(obj == '禁用管理'){
          this.dialog.disableStatus = true
        }else if(obj == '身份设置'){
          this.dialog.identityStatus = true
        }else if(obj == '礼物兑换记录'){
          this.dialog.exchangeStatus = true
        }else if(obj == '礼物记录'){
          this.dialog.giftStatus = true
        }
      },
      // 点击查询事件
      query() {
        this.formInline.pageNum = 1
        this.getList()
      },
      // 操作成功的钩子用来更新列表
      success() {
        this.getList()
      },
      // 关闭弹窗返回的钩子
      close() {
        this.dialog.status = false;
      },

      // pageSize发生改变触发
      handleSizeChange(val) {
        this.pageNum = 1
        this.pageSize = val
        this.getList()
      },
      // pageNum 发生改变触发
      handleCurrentChange(val) {
        this.formInline.pageNum = val
        this.getList()
      },
      // 删除用户
      onDelete(id, usernameParam,index) {
        this.$confirm('是否删除该用户?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // adminDeleteAPI(id,usernameParam).then(res => {
          //   if (res.code === 200) {
          //     this.$message.success(res.message)
          //     this.getUserList()
          //   } else {
          //     this.$message.error(res.message)
          //   }
          // })
        }).catch(() => {

        });
      },
      // 获取提现记录
      getList() {
        this.loading = true
        getWithdrawListAPI(this.formInline).then(res => {
          this.loading = false
          if (res.rtnInfo.code === 0) {
            this.tableData = res.rtnInfo.data.list
            this.formInline.total = res.rtnInfo.data.total
          } else {
            this.$message.error(res.message)
          }
        })
      }
    }
  }
</script>
<style>
</style>

